<template>
  <div>
    <search-hander @handleSearch="handleSearch">
      <template>
        <span>型号搜索：</span>
      </template>
    </search-hander>
    <div class="main">
      <div class="btnBox">
        <el-button class="btn" @click="addDevice">
          <i class="el-icon-circle-plus-outline" />
          新建
        </el-button>
      </div>
      <el-table :data="list" style="width: 100%">
        <el-table-column label="序号" width="70">
          <template v-slot="{$index}">
            {{ ($index + 1) + (params.pageIndex - 1) * 10 }}
          </template>
        </el-table-column>
        <el-table-column prop="name" label="型号名称" />
        <el-table-column prop="model" label="型号编码" />
        <el-table-column prop="image" label="设备图片">
          <template v-slot="{row}">
            <img v-if="row.image" style="width:24px;height:24px" :src="row.image">
            <span v-else>暂无</span>
          </template>
        </el-table-column>
        <el-table-column prop="vmCol" label="货道行" />
        <el-table-column prop="vmRow" label="货道列" />
        <el-table-column prop="channelMaxCapacity" label="设备容量" />
        <el-table-column fixed="right" label="操作" width="180">
          <template v-slot="{row}">
            <el-button type="text" @click="putRegion(row)">修改</el-button>
            <el-button type="text" @click="deleteRegion(row.id)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-row v-if="totalPage > 1" align="middle" justify="space-between" style="height: 60px" type="flex">
        <span style="color: #dbdfe5">共{{ totalCount }}条记录  第 {{ params.pageIndex }}/{{ totalPage }} 页</span>
        <el-pagination
          :current-page="params.pageIndex"
          :page-size="params.pageSize"
          :total="+totalCount"
          layout="prev, next"
          next-text="下一页"
          prev-text="上一页"
          @current-change="changePage"
        />
      </el-row>
    </div>
  </div>
</template>

<script>
import { getTypeList } from '@/api/type'
import SearchHander from '@/components/SearchHander'
export default {
  components: { SearchHander },
  data() {
    return {
      params: {
        pageIndex: 1,
        pageSize: 10
      },
      list: [],
      totalCount: 0,
      totalPage: 0,
      // showAddDialog: false,
      // showPutDialog: false,
      form: {
        regionName: '',
        remark: ''
      }
    }
  },
  created() {
    this.getList()
  },
  methods: {
    async getList() {
      const res = await getTypeList(this.params)
      this.list = res.currentPageRecords
      this.totalCount = res.totalCount
      this.totalPage = res.totalPage
      console.log(this.list)
    },
    putRegion() {},
    deleteRegion() {},
    addDevice() {},
    handleSearch() {},
    changePage(page) {
      this.params.pageIndex = page
      this.getList(this.params)
    }
  }
}

</script>

<style scoped>
.main{
  width: 100%;
  height: 693px;
  padding: 20px;
  background-color: #fff;
  margin-bottom: 70px;
}
.btnBox {
  display: flex;
  padding-bottom: 20px;
}
.btn {
  display: flex;
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  justify-content: center;
  -webkit-box-align: center;
  -ms-flex-align: center;
  align-items: center;
  width: 80px ;
  height: 36px;
  padding: 0;
  background: linear-gradient(135deg, #ff9743, #ff5e20) ;
  border: none;
  color: white;
}
::v-deep .el-pagination button {
width: 70px;
height: 32px;
margin: 0 16px;
border-radius: 2px;
background-color: #d5ddf8;
}
::v-deep .btn-prev:disabled {
background: #edf0f9;
}
::v-deep .el-table td, .el-table th {
  padding: 5px 0;
}
::v-deep .el-table td, .el-table th.is-leaf{
  border-bottom: 0;
}
</style>
